package com.etc.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.io.DataInputStream;
import java.io.DataOutputStream;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;

import com.etc.entity.Counter;

public class SelectHero extends JPanel {

	public SelectHero() {

	}

	@Override
	public void paint(Graphics g) {
		Image pic1, pic2, pic3;
		ImageIcon icon;
		super.paint(g);
		icon = new ImageIcon("pic/p1.png");
		pic1 = icon.getImage();
		g.drawImage(pic1, 50, 0, null);

		icon = new ImageIcon("pic/p2.png");
		pic2 = icon.getImage();
		g.drawImage(pic2, 550, 0, 427, 394, null);

		icon = new ImageIcon("pic/p3.png");
		pic3 = icon.getImage();
		g.drawImage(pic3, 1050, 0, 427, 394, null);

		paintComponents(g);
	}

	public Component setText(SelectHero sh, JFrame jFrame, Counter counter, DataOutputStream dos, DataInputStream dis, JPanel jpanel) {
		
		sh.setLayout(null);
		sh.setBackground(Color.LIGHT_GRAY);
		JTextPane hero1 = new JTextPane();
		hero1.setBounds(50, 400, 427, 150);
		hero1.setFont(new Font("楷体", Font.BOLD, 16));
		hero1.setForeground(Color.black);
		hero1.setText(
				"英雄简介:横扫千军意气重，破釜沉舟慨而慷。大唐子弟曾随唐皇征战天下，立下汗马功劳，门派师父程咬金更是凌烟阁功臣榜上第一猛将。门下弟子个个骁勇威武，不仅深谙为官之道，更具文韬武略。其武功招式偏 重物理攻击，以强大的爆发力著称。");
		sh.add(hero1);

		JTextPane hero2 = new JTextPane();
		hero2.setBounds(550, 400, 427, 150);
		hero2.setFont(new Font("楷体", Font.BOLD, 16));
		hero2.setForeground(Color.black);
		hero2.setText(
				"英雄2简介:三昧火飞砂走石，氏族力魔王降临。四海有名称混世，西方大力号魔王。平天大圣牛魔王聚集四万三千妖众成立此门派，行动威风气势赫赫，崇武尚勇斗能争强。魔王寨门下弟子深悉火中真性而得暴击之法，三昧真火炎天炽地，飞砂走石日月无光。更能召唤印记，烈焰予对手重创，守护补己方气血。");
		sh.add(hero2);

		JTextPane hero3 = new JTextPane();
		hero3.setBounds(1050, 400, 427, 150);
		hero3.setFont(new Font("楷体", Font.BOLD, 16));
		hero3.setForeground(Color.black);
		hero3.setText(
				"怀月刃，步月影，月影轻似梦，刃芒细如眉。羽衣新曲步夜露，广寒凝月醉清辉。霜华伴月，但见阴晴圆缺。月宫弟子受月灵引导，善于利用时之月的变化而发动攻势。在圆月下踏月刃起舞显露杀机，在月暗时借寒魄冰轮控制对手，更能在月光的笼罩中发挥出极大的攻击力，予敌人以重创。相逢桂丛下，决战月明中，不负广寒深醉");
		sh.add(hero3);

		JButton jButton1 = new JButton("选择职业");
		jButton1.setBounds(50, 580, 427, 30);
		sh.add(jButton1);

		JButton jButton2 = new JButton("选择职业");
		jButton2.setBounds(550, 580, 427, 30);
		sh.add(jButton2);

		JButton jButton3 = new JButton("选择职业");
		jButton3.setBounds(1050, 580, 427, 30);
		sh.add(jButton3);

		//监听按钮1，返回大唐职业的classId
		jButton1.addActionListener(e -> {
			jFrame.setVisible(false);
			JFrame frame = new JFrame("装备界面");
			String classId = null;
			JPanel panel = new JPanel();
			frame.setVisible(true);
			frame.setBounds(100, 100, 400, 300);
			frame.add(panel);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			classId = "d608832e";
			new SelectEquip().selecEquip(panel, classId, frame, counter, dos, dis);
		});
		//监听按钮2，返回魔王寨职业的classId
		jButton2.addActionListener(e -> {
			jFrame.setVisible(false);
			JFrame frame = new JFrame("装备界面");
			String classId = null;
			JPanel panel = new JPanel();
			frame.setVisible(true);
			frame.setBounds(100, 100, 400, 300);
			frame.add(panel);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			classId = "3d22d341";
			new SelectEquip().selecEquip(panel, classId, frame, counter, dos, dis);
		});
		//监听按钮3，返回月宫职业的classId
		jButton3.addActionListener(e -> {
			jFrame.setVisible(false);
			JFrame frame = new JFrame("装备界面");
			String classId = null;
			JPanel panel = new JPanel();
			frame.setVisible(true);
			frame.setBounds(100, 100, 400, 300);
			frame.add(panel);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			classId = "5a967488";
			new SelectEquip().selecEquip(panel, classId, frame, counter, dos, dis);
		});

		return sh.add(hero1);
	}

	public static void main(String[] args) {

	}
}
